package com.fengxu.gamescript.jsengine.core;

import com.fengxu.gamescript.jsengine.exception.ScriptInterruptException;
import com.fengxu.gamescript.jsengine.exception.ScriptRunningException;

import org.mozilla.javascript.tools.shell.ShellContextFactory;
import org.mozilla.javascript.Context;

public class AndroidContextFactory extends ShellContextFactory {

    public AndroidContextFactory() {}


    @Override
    protected void observeInstructionCount(Context cx, int instructionCount) {
        if (Thread.currentThread().isInterrupted()) {
            throw new ScriptInterruptException();
        }
    }

    @Override
    protected Context makeContext() {
        Context cx = super.makeContext();
        cx.setInstructionObserverThreshold(10000);
        return cx;
    }


}